﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BI.DAL;
using CentaLine.Infrastructure;
using NUnit.Framework;

namespace BI.NUnitTest
{
    [TestFixture]
    public class Test
    {
        /// <summary>
        /// 日志测试
        /// </summary>
        [Test]
        public void LoggerTest()
        {
            Logger.Log.Info("测试");
        }

        /// <summary>
        /// 缓存测试
        /// </summary>
        [Test]
        public void CacheTest()
        {
            string key = "TestKey";
            if (CacheHelper.Contains(key))
            {
                var data = CacheHelper.Get(key);
                Logger.Log.Info("已存在缓存-" + data);
            }
            else
            {
                Logger.Log.Info("插入缓存");
                CacheHelper.AddHours(key, "缓存数据-"+DateTime.Now, 2);
            }
        }

        /// <summary>
        /// 数据库链接测试
        /// </summary>
        [Test]
        public void DBTest()
        {
            TestRepository tr = new TestRepository();
            string name = string.Empty;
            var res = tr.TestGetDataFromDB("A002");
            if (res != null && res.Tables.Count > 0)
            {
                name = res.Tables[0].Rows[0]["empname"].ToString();
            }

            Assert.AreEqual(name.Trim(), "谭百强");
        }

    }
}
